static gboolean
gtk_css_ruleset_matches (GtkCssRuleset *ruleset,
- GtkWidgetPath *path)
+ GtkWidgetPath *path,
+ GtkStateFlags state)
{
- return _gtk_css_selector_matches (ruleset->selector,
- path,
- gtk_widget_path_length (path));
+ return _gtk_css_selector_matches (ruleset->selector, path, state);
}
static void
if (ruleset->style == NULL)
continue;
- if (!gtk_css_ruleset_matches (ruleset, path))
+ if (!gtk_css_ruleset_matches (ruleset, path, 0))
continue;
g_hash_table_iter_init (&iter, ruleset->style);
for (i = priv->rulesets->len - 1; i >= 0; i--)
{
GtkCssRuleset *ruleset;
- GtkStateFlags selector_state;
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
if (ruleset->widget_style == NULL)
continue;
- if (!gtk_css_ruleset_matches (ruleset, path))
+ if (!gtk_css_ruleset_matches (ruleset, path, state))
continue;
- selector_state = _gtk_css_selector_get_state_flags (ruleset->selector);
val = g_hash_table_lookup (ruleset->widget_style, prop_name);
- if (val &&
- (selector_state == 0 ||
- selector_state == state ||
- ((selector_state & state) != 0 &&
- (selector_state & ~(state)) == 0)))
+ if (val)
{
GtkCssScanner *scanner;
GtkCssRuleset *ruleset;
GHashTableIter iter;
gpointer key, val;
- GtkStateFlags selector_state;
ruleset = &g_array_index (priv->rulesets, GtkCssRuleset, i);
if (ruleset->style == NULL)
continue;
- selector_state = _gtk_css_selector_get_state_flags (ruleset->selector);
- if ((selector_state & state) != selector_state)
- continue;
-
- if (!gtk_css_ruleset_matches (ruleset, path))
+ if (!gtk_css_ruleset_matches (ruleset, path, state))
continue;
g_hash_table_iter_init (&iter, ruleset->style);
* _gtk_css_selector_matches:
* @selector: the selector
* @path: the path to check
- * @length: How many elements of the path are to be used
+ * @state: The state to match
*
* Checks if the @selector matches the given @path. If @length is
* smaller than the number of elements in @path, it is assumed that
gboolean
_gtk_css_selector_matches (const GtkCssSelector *selector,
const GtkWidgetPath *path,
- guint length)
+ GtkStateFlags state)
{
GSList *list;
gboolean match;
+ guint length;
g_return_val_if_fail (selector != NULL, FALSE);
g_return_val_if_fail (path != NULL, FALSE);
- g_return_val_if_fail (length <= gtk_widget_path_length (path), FALSE);
+ if ((selector->state & state) != selector->state)
+ return FALSE;
+
+ length = gtk_widget_path_length (path);
if (length == 0)
return FALSE;